//
//  ImageHelper.h
//  CarCare
//
//  Created by ileo on 14-9-29.
//  Copyright (c) 2014年 baozun. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AFNetworking/UIImageView+AFNetworking.h>

#define ImageNamed(name) [UIImage imageNamed:name]
#define ImageOnceType(name,type)  [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:type]]
#define ImageOncePNG(name)  [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:@"png"]]

#define COLOR_HEXSTRING(hexStr) [UIColor colorWithHexString:hexStr]

// rgb颜色转换（16进制->10进制）
#define COLOR_RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
@interface ImageHelper : NSObject

/**
 *  给图片上色
 */
+(UIImage *)renderImage:(UIImage *)aImage withColor:(UIColor *)color;

/**
 *  给图片透明度
 */
+ (UIImage *) setImage:(UIImage *)image withAlpha:(CGFloat)alpha;

/**
 *  从中间裁剪图片
 */
+(UIImage *)cutImage:(UIImage *)aImage centerSize:(CGSize)size;

/**
 *  裁剪图片
 */
+(UIImage *)cutImage:(UIImage *)aImage rect:(CGRect)rect;


/**
 *  纯色图片
 */
+(UIImage *)imageWithSolidColor:(UIColor *)color size:(CGSize)size;

/**
 *  圆角图片
 */
+(UIImage *)cornerImage:(UIImage *)aImage cornerRadius:(CGFloat)radius;

/**
 *  给图片加水印
 */
+(UIImage *)watermarkImage:(UIImage *)image withText:(NSString *)text;

/**
 *  获取View的截图
 */
+(UIImage *)imageRenderFromView:(UIView *)aView;

/**
 *  缩放image
 */
+(UIImage *)scaleImage:(UIImage *)image toScale:(float)scaleSize;


/**
 *  压缩到指定大小  单位b   eg:1k ＝ 1024b
 */

+(NSData *)dataWithImage:(UIImage *)aImage compressLength:(CGFloat)length ;

+(NSURLRequest *)requestURLWithURLStr:(NSString *)str;


//二维码生成
+(UIImage *)qrImageForString:(NSString *)string size:(CGFloat)size;

@end

